package com.wangzhen.jvm;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;

public class AddClassUrlDemo {

    public static void main(String[] args) throws NoSuchMethodException, MalformedURLException, InvocationTargetException, IllegalAccessException {
        ClassLoader classLoader = AddClassUrlDemo.class.getClassLoader();
        Method addURLMethod = ClassLoader.class.getDeclaredMethod("addURL", URL.class);
        addURLMethod.setAccessible(true);

        URL url = new URL("file:/d:/aaa");
        addURLMethod.invoke(classLoader, url);

    }
}
